package org.xxforest.game.core.scenes.scene2d.graphics;

import org.xxforest.game.core.scenes.scene2d.XXNode;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class XXParticle extends XXNode {
	
	protected String particleFile ;
	protected String imagePath ;
	protected ParticleEffect particle;

	public XXParticle(String particleFile , String imagePath){
		this.particleFile = particleFile ;
		this.imagePath = imagePath ;
		
		particle = new ParticleEffect() ;
		particle.load(Gdx.files.internal(particleFile),Gdx.files.internal(imagePath));
		particle.start() ;
	}
	
	public static XXParticle create(String particleFile){
		return create(particleFile, "") ;
	}
	
	public static XXParticle create(String particleFile , String imagePath){
		return new XXParticle(particleFile,imagePath) ;
	}
	
	@Override
	public void draw(SpriteBatch batch , float delata) {
		particle.setPosition(getDrawX(), getDrawY()) ;
		particle.draw(batch,delata);
	}

	@Override
	public void onCreate() {
	}

	public void reset() {
		particle.reset();
	}

	public boolean isComplete() {
		return particle.isComplete();
	}

	@Override
	public void dispose() {
		super.dispose();
		particle.dispose() ;
	}
	
}
